Skip to content

Drop 10 work item across 1851 and 1873 story - #19

Open
KUNALTEMPEST wants to merge 3 commits into
ELEVATE-Project:release-1.2.0from
darshilbabel:drop_10_work
Open

Drop 10 work item across 1851 and 1873 story#19
KUNALTEMPEST wants to merge 3 commits into
ELEVATE-Project:release-1.2.0from
darshilbabel:drop_10_work

Conversation

@KUNALTEMPEST

@KUNALTEMPEST KUNALTEMPEST commented Aug 4, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added thumbs-up/thumbs-down ratings and optional comments for company chat responses.
    • Chat responses now display their latest feedback status.
    • Added profile update support for non-empty profile fields.
    • Expanded supported languages to English, Hindi, Kannada, Telugu, Odia, and Tamil.
  • Administration

    • Added read-only feedback history to company chat records.
  • Documentation

    • Improved Gotenberg setup and verification instructions for Docker deployments.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: aeabb7ae-a56e-445f-9279-ea2e03db2e95

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds company chat feedback storage and APIs, exposes latest reactions in chat responses, adds read-only admin feedback history, introduces a profile update endpoint, changes language choices, and updates Gotenberg deployment documentation.

Changes

Company chat feedback

Layer / File(s) Summary
Feedback persistence
chatbot/models/company_models.py, chatbot/migrations/...
Adds CompanyChatFeedback with reactions, comments, timestamps, cascading chat deletion, newest-first ordering, and an index.
Feedback serialization and chat output
chatbot/serializer/profile_serializer.py
Exposes latest reactions and validates reaction and comment submissions.
Feedback API integration
chatbot/views/drf_views.py, chatbot/urls.py
Prefetches feedback for chat endpoints and adds a create-only feedback endpoint.
Feedback administration
chatbot/admin/company_admin.py
Displays read-only feedback history and removes moderator-specific chat queryset and filter logic.

Language schema updates

Layer / File(s) Summary
Language field migration
chatbot/migrations/...
Updates language choices for ChatSession, Story, and StoryTranslation, including the StoryTranslation length constraint.

Profile update API

Layer / File(s) Summary
Profile update endpoint
chatbot/views/api_views.py, chatbot/urls.py
Adds a PATCH endpoint that validates fields, calls Elevate, handles failures, and returns updated field names.

Gotenberg setup documentation

Layer / File(s) Summary
Deployment and verification instructions
docs/setup/gotenberg_server_setup.md
Documents dynamic container detection, custom image setup, Docker Compose, plain Docker, and environment-based verification.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CompanyChatFeedbackCreateView
  participant CompanyChatFeedbackSerializer
  participant CompanyChatFeedback
  Client->>CompanyChatFeedbackCreateView: POST company chat feedback
  CompanyChatFeedbackCreateView->>CompanyChatFeedbackSerializer: Validate submission
  CompanyChatFeedbackSerializer->>CompanyChatFeedback: Create feedback history entry
  CompanyChatFeedbackCreateView-->>Client: Return feedback response
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title does not describe the primary changes, which add company chat feedback functionality and profile updates. Use a title that identifies the main changes, such as adding company chat feedback support and profile update handling.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@KUNALTEMPEST

Copy link
Copy Markdown
Author

@coderabbitai review, (you can ignore docs folder)

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

@KUNALTEMPEST I will review pull request #19. I will ignore changes in the docs folder.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@chatbot/admin/company_admin.py`:
- Around line 335-337: Update CompanyChatAdmin.get_queryset to apply the
moderator company restriction directly to the base queryset, following the
existing filtering pattern in BotAdmin and ChatSessionAdmin. Preserve the
sender__company and receiver__company prefetches while ensuring moderators
cannot see non-company CompanyChat rows in the default result.

In `@chatbot/serializer/profile_serializer.py`:
- Around line 96-100: Update CompanyChatSerializer._latest_feedback in
chatbot/serializer/profile_serializer.py:96-100 and the related feedback
prefetches in chatbot/views/drf_views.py:20-21 and
chatbot/views/drf_views.py:27-28 so each chat loads only its latest feedback
row, or supplies a precomputed latest-feedback value; preserve thumbs_up and
thumbs_down selection while avoiding full feedback-history materialization.
- Around line 129-138: Move the omitted-reaction-field fallback out of
CompanyChatFeedbackSerializer.validate and into the feedback creation path,
using an atomic transaction that locks the latest CompanyChatFeedback for the
company_chat before copying thumbs_up/thumbs_down and creating the new row.
Preserve explicit reaction values and ensure comment-only submissions cannot
overwrite newer reaction state.

In `@chatbot/views/api_views.py`:
- Around line 358-359: Update the profile update flow around
update_elevate_profile so personal profile values are not emitted in INFO logs;
replace full request/response logging in the called profile utility with field
names and status codes only, or use the project’s approved redaction helper,
while preserving the update behavior.
- Around line 358-359: Update update_profile_view to construct the
profile-update payload only from fields requested by the frontend, including
about only when explicitly provided; ensure update_elevate_profile does not
inject its placeholder about value. Preserve existing supported-field filtering
and add a mocked request test verifying a name-only update sends no about key.
- Around line 358-359: Update the access-token flow in the surrounding view to
check whether _get_access_token(request) returned None before calling
update_elevate_profile. Match the existing guard and 401 Unauthorized response
used by update_profile_view, ensuring requests without either token source
return immediately and never invoke update_elevate_profile with a missing token.
- Around line 346-350: Update the update_fields construction in the profile
update handler to include only values that are strings containing non-whitespace
characters, excluding False, 0, empty strings, and whitespace-only strings.
Ensure the response’s updated-field list is derived from this validated set so
rejected values are not reported as updated.
- Around line 381-386: Update the exception handler around the affected API view
to use logger.exception(...) for structured server-side diagnostics instead of
traceback.print_exc(), while retaining the existing logger context. Return a
generic 500 error message without exposing str(e) to clients, and address Ruff’s
blind except Exception warning using the project’s established
exception-handling pattern.

In `@chatbot/views/drf_views.py`:
- Around line 32-35: Restrict feedback creation in CompanyChatFeedbackCreateView
so callers cannot submit an arbitrary company_chat. Either scope the writable
company_chat field in CompanyChatFeedbackSerializer to chats authorized for the
caller, or make it read-only and resolve the authorized chat in perform_create
before saving.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a68e9cdb-6765-485e-9e5a-bfa12b05cd17

📥 Commits

Reviewing files that changed from the base of the PR and between 1bde8db and e6600e8.

📒 Files selected for processing (8)
  • chatbot/admin/company_admin.py
  • chatbot/migrations/0089_alter_chatsession_language_alter_story_language_and_more.py
  • chatbot/models/company_models.py
  • chatbot/serializer/profile_serializer.py
  • chatbot/urls.py
  • chatbot/views/api_views.py
  • chatbot/views/drf_views.py
  • docs/setup/gotenberg_server_setup.md

Comment thread chatbot/admin/company_admin.py Outdated
Comment thread chatbot/serializer/profile_serializer.py Outdated
Comment thread chatbot/serializer/profile_serializer.py Outdated
Comment thread chatbot/views/api_views.py Outdated
Comment thread chatbot/views/api_views.py
Comment thread chatbot/views/api_views.py Outdated
Comment thread chatbot/views/drf_views.py
@KUNALTEMPEST

Copy link
Copy Markdown
Author

@coderabbitai review, please resolve the comments if they are fixed now

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ELEVATE-Project/saathi-backend"
pr="19"

echo "== Pull request =="
gh pr view "$pr" --repo "$repo" --json number,state,headRefOid,baseRefOid,changedFiles,commits \
  --jq '{number,state,headRefOid,baseRefOid,changedFiles,commitCount:(.commits|length)}'

echo "== Changed files excluding docs =="
gh pr diff "$pr" --repo "$repo" --name-only | awk '$0 !~ /^docs\//'

echo "== CodeRabbit review threads =="
gh api graphql \
  -F owner="ELEVATE-Project" \
  -F name="saathi-backend" \
  -F number="$pr" \
  -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          id
          isResolved
          path
          line
          originalLine
          comments(first: 20) {
            nodes {
              author { login }
              body
              createdAt
              url
            }
          }
        }
      }
    }
  }
}' \
  --jq '.data.repository.pullRequest.reviewThreads.nodes[]
    | select(any(.comments.nodes[]; .author.login == "coderabbitai"))
    | {id,isResolved,path,line,originalLine,comments:[.comments.nodes[] | select(.author.login == "coderabbitai") | {body,url,createdAt}]}'

Length of output: 35884


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Current symbol map =="
ast-grep outline chatbot/admin/company_admin.py --match CompanyChatAdmin --view expanded
ast-grep outline chatbot/serializer/profile_serializer.py --match 'CompanyChatSerializer|CompanyChatFeedbackSerializer' --view expanded
ast-grep outline chatbot/views/api_views.py --match update_profile_view --view expanded
ast-grep outline chatbot/views/drf_views.py --match 'CompanyChatListCreateView|CompanyChatRetrieveUpdateDestroyView|CompanyChatFeedbackCreateView' --view expanded
ast-grep outline chatbot/utils/elevate/profile_utils.py --match update_elevate_profile --view expanded

echo "== Relevant current source =="
rg -n -C 12 --type py \
  'class CompanyChatAdmin|def get_queryset|class CompanyChatSerializer|_latest_feedback|class CompanyChatFeedbackSerializer|def validate|def create' \
  chatbot/admin/company_admin.py chatbot/serializer/profile_serializer.py

rg -n -C 12 --type py \
  'def update_profile_view|update_fields|update_elevate_profile|logger\.|traceback|except Exception' \
  chatbot/views/api_views.py chatbot/utils/elevate/profile_utils.py

rg -n -C 10 --type py \
  'class CompanyChatListCreateView|class CompanyChatRetrieveUpdateDestroyView|class CompanyChatFeedbackCreateView|prefetch_related|Prefetch' \
  chatbot/views/drf_views.py

echo "== Diff after base commit, excluding docs =="
git diff --no-ext-diff --unified=16 1bde8dbd3fd0898b7e8911e117156b728c2a6fbf..HEAD -- \
  chatbot/admin/company_admin.py \
  chatbot/serializer/profile_serializer.py \
  chatbot/views/api_views.py \
  chatbot/utils/elevate/profile_utils.py \
  chatbot/views/drf_views.py

Length of output: 89941


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ELEVATE-Project/saathi-backend"
pr="19"
thread_ids=(
  "PRRT_kwDOSaCc8s6WLuC4"
  "PRRT_kwDOSaCc8s6WLuC8"
  "PRRT_kwDOSaCc8s6WLuC_"
  "PRRT_kwDOSaCc8s6WLuDC"
  "PRRT_kwDOSaCc8s6WLuDJ"
)

for thread_id in "${thread_ids[@]}"; do
  gh api graphql \
    -F threadId="$thread_id" \
    -f query='
mutation($threadId: ID!) {
  resolveReviewThread(input: {threadId: $threadId}) {
    thread { id isResolved }
  }
}' \
    --jq '.data.resolveReviewThread.thread | {id,isResolved}'
done

echo "== Remaining unresolved CodeRabbit threads =="
gh api graphql \
  -F owner="ELEVATE-Project" \
  -F name="saathi-backend" \
  -F number="$pr" \
  -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          id
          isResolved
          path
          comments(first: 20) { nodes { author { login } url } }
        }
      }
    }
  }
}' \
  --jq '.data.repository.pullRequest.reviewThreads.nodes[]
    | select(.isResolved == false)
    | select(any(.comments.nodes[]; .author.login == "coderabbitai"))
    | {id,path,commentUrls:[.comments.nodes[] | select(.author.login == "coderabbitai") | .url]}'

Length of output: 1949


@KUNALTEMPEST I reviewed the current non-docs changes and resolved five CodeRabbit threads that the code now addresses.

One thread remains open in chatbot/views/api_views.py. The endpoint still sends a missing access token to Elevate. The earlier discussion explicitly accepts this behavior. I left the thread open because the code does not implement the original guard.

You are interacting with an AI system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant